package com.iwish.server.model;

import org.apache.mina.core.buffer.IoBuffer;
import org.apache.mina.core.session.IoSession;
import org.apache.mina.filter.codec.CumulativeProtocolDecoder;
import org.apache.mina.filter.codec.ProtocolDecoderOutput;

public class RequestPacketDecoder extends CumulativeProtocolDecoder {

	private static final byte HEADER_LEN = 24;
	
	
    protected boolean doDecode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) throws Exception {
        if (in.remaining() >= HEADER_LEN) {
            int width = in.getInt();
            int height = in.getInt();
            int numberOfCharachters = in.getInt();
            MessagePacket request = new MessagePacket();
            out.write(request);
            return true;
        } 
        else {
            return false;
        }
    }
}
